﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using Ninject.Modules;

namespace IOCSolution.Ninject
{
    public class NinjectRunner : IRunner
    {
        private IKernel _kernel;

        public string Name
        {
            get { return "Ninject"; }
        }

        public void Init()
        {
            _kernel = new StandardKernel(new InitNinjectModule());
        }

        public void Start()
        {
            Console.WriteLine("\r\nthis name: " + Name);
            var manager = _kernel.Get<DatabaseHelper>();
            manager.Search("select * from users");
        }
    }

    public class InitNinjectModule : NinjectModule
    {
        public override void Load()
        {
            Bind<IDatabase>().To<OracleDatabase>();
            Bind<DatabaseHelper>().ToSelf().InSingletonScope();
        }
    }
}
